Unit BFormMainUnit;

{$mode objfpc}{$H+}

Interface

Uses
  Classes, SysUtils, BSessionUnit, BDojoxFloatingPaneUnit,
    BDojoItemFileWriteStoreUnit, BDijitBorderContainerUnit, BDojoxDataGridUnit;

Type

{ BFormMainClass }

 BFormMainClass = Class(BDojoxFloatingPaneClass)
  Private
    bContainer: BDijitBorderContainerClass;
    bDataGrid: BDojoxDataGridClass;
    bStore: BDojoItemFileWriteStoreClass;

    Procedure BuildLayout;
  Public
    Property Store: BDojoItemFileWriteStoreClass Read bStore;
    Property DataGrid: BDojoxDataGridClass Read bDataGrid;
    Property Container: BDijitBorderContainerClass Read bContainer;
    Constructor Build(Const aSession: BSessionClass);
End;

Implementation

{ BFormMainClass }

Procedure BFormMainClass.BuildLayout;
Begin
  bStore := BDojoItemFileWriteStoreClass.Build(Session);
  bStore.Data :=
    'items: [{' +
      'id: 0, ' +
      'caption: "Caption 1", ' +
      'shortcut: "Shortcut 1"' +
    '},{' +
      'id: 1, ' +
      'caption: "Caption 2", ' +
      'shortcut: "Shortcut 2"' +
    '},{' +
      'id: 2, ' +
      'caption: "Caption 3", ' +
      'shortcut:"Shortcut 3"' +
    '},{' +
      'id: 3, ' +
      'caption: "Caption 4", ' +
      'shortcut: "Shortcut 4"' +
    '}]';

  bDataGrid := BDojoxDataGridClass.Build(Session);
  bDataGrid.Store := bStore;
  bDataGrid.Region := 'center';
  bDataGrid.Structure :=
    '[' +
      '{name: "Caption", field: "caption", width: "200px" },' +
      '{name: "Shortcut", field: "shortcut", width: "200px" }' +
    ']';

  bContainer := BDijitBorderContainerClass.Build(Session);
  bContainer.AddChild(bDataGrid);

End;

Constructor BFormMainClass.Build(Const aSession: BSessionClass);
Begin
  Inherited Build(aSession);
  Resizable := TRUE;
  Title := 'DataGrid1';
  Style := 'width: 640px; height: 480px;';

  BuildLayout;
  ContentObj := bContainer;

  Startup;
End;

End.

